<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="jakarta.faces.html" xmlns:p="http://primefaces.org/ui"
  xmlns:ui="jakarta.faces.facelets">
<ui:composition template="/WEB-INF/templates/common/admin.xhtml">
  <ui:define name="title">Cargo Registration</ui:define>
  <ui:define name="content">
    <div class="ui-g-2" id="leftCol"></div>
    <div class="ui-g-8" id="mainCol">
      <br />
      <h:form id="dateForm">
        <p:outputLabel
          value="3. Set the arrival deadline for this new #{booking.originName}-#{booking.destinationName} cargo " />
        <hr />
        <h:panelGrid columns="1" styleClass="registrationPanelGrid"
          style="margin: 0 auto;">
          <p:calendar id="deadline" value="#{booking.arrivalDeadline}"
            mindate="#{booking.today}" mode="inline" pattern="yyyy-MM-dd">
            <p:ajax event="dateSelect" listener="#{booking.deadlineUpdated}" />
          </p:calendar>
        </h:panelGrid>
        <h:panelGrid columns="1" id="durationPanel"
          styleClass="registrationPanelGrid" style="margin: 0 auto;">
          <p:outputLabel value="A journey can't start and end the same day!"
            rendered="#{booking.duration eq 0}" />
          <p:outputLabel value="Journey duration is one day."
            rendered="#{booking.duration eq 1}" />
          <p:outputLabel value="Journey duration is #{booking.duration} days."
            rendered="#{booking.duration gt 1}" />
        </h:panelGrid>
        <hr />
        <h:panelGrid columns="3" styleClass="registrationPanelGrid"
          style="margin: 0 auto;">
          <p:commandButton value="Back" action="booking-destination" />
          <p:commandButton value="Cancel" action="/admin/dashboard" />
          <p:commandButton value="Book Cargo" id="bookBtn"
            action="#{booking.register()}" disabled="#{!booking.bookable}" />
        </h:panelGrid>
      </h:form>
    </div>
  </ui:define>
</ui:composition>
</html>
